package com.starbaba.buriedPoint.view;

import java.io.IOException;
import java.util.List;

import com.base.common.log.LogService;
import com.opensymphony.xwork2.ModelDriven;
import com.starbaba.buriedPoint.service.CommonActivityRegisterDisplayService;
import com.starbaba.buriedPoint.service.impl.CommonActivityRegisterDisplayServiceImpl;
import com.starbaba.core.utils.PropertyParamMapBuilder;
import com.starbaba.core.utils.Struts2Utils;
import com.starbaba.core.utils.json.JsonUtils;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.core.web.struts2.BaseAction;
import com.tuanzi.server.loan_base.model.db.Common_Activity_Register_Record;

/**
 * 通用活动登记实时展示后台 action
 * @author chenweijun 2017/10/16
 *
 */
@SuppressWarnings({"unchecked","rawtypes","serial"})
public class CommonActivityRegisterDisplayAction extends BaseAction implements ModelDriven<Common_Activity_Register_Record>{
	
	private Common_Activity_Register_Record model;
	private CommonActivityRegisterDisplayService service;
	
	
	private CommonActivityRegisterDisplayAction(){
		this.service = new CommonActivityRegisterDisplayServiceImpl();
	}

	@Override
	public Common_Activity_Register_Record getModel() {
		if(model == null){
			model = new Common_Activity_Register_Record();
		}
		return model;
	}
	
	public void getList() throws IOException{
		
		parsePageRequest();
		PageResponse pageResponse=new PageResponse();
		paramsMap=PropertyParamMapBuilder.buildFromHttpRequest(Struts2Utils.getRequest(), paramsMap);
		List<Common_Activity_Register_Record> list = service.getList(paramsMap, 
				pageRequest.getIDisplayStart(), pageRequest.getIDisplayLength());
		int count = service.countList(paramsMap);
		pageResponse.setITotalDisplayRecords(count);
		pageResponse.setITotalRecords(count);
		pageResponse.setAaData(list);
		
		try {
			
			sendJsonMessage(JsonUtils.toJson(pageResponse, null, true, null, false));
			
		} catch(IOException e) {
			LogService.error(e);
		}
		
	}

}
